package com.ajz.manager.api;

import javax.inject.Inject;

import org.springframework.security.core.AuthenticationException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ajz.common.constants.SwaggerApiConstant;
import com.ajz.common.dto.Result;
import com.ajz.manager.entity.SysAppVersion;
import com.ajz.manager.service.MemberService;
import com.ajz.manager.service.SysAppVersionService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/api")
public class ApiController {
	@Inject
	private MemberService memberService;
    /**
     * 刷新token
     *
     * @param authorization 原token
     * @return 新密钥
     * @throws AuthenticationException 错误信息
     */
	@ApiOperation(value = SwaggerApiConstant.TOKEN_REFRESH)
    @GetMapping(value = "/refreshToken")
    public Result refreshToken(@RequestHeader String authorization) throws AuthenticationException {
		String token = memberService.refreshToken(authorization);
		if(token.equals("error")) {
			return Result.errorResult(token);
		}
        return Result.successResult(token);
    }
	
}
